package utils;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * map reduce lambda
 */
public class lambda4 {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
        List<Integer> doubleNumbers = numbers.stream()
                .map(number -> number * 2)
                .collect(Collectors.toList());

        List<String> stringNumbers = numbers.stream()
                .map(number -> "#" + number)
                .collect(Collectors.toList());

        Optional<Integer> integerOptional = numbers.stream().reduce((a, b) -> a+b);
        int sum = integerOptional.get();
    }
}
